/*
 *  BaseCat.h
 *  Untitled
 *
 *  Created by Guo Wei Tan on 1/20/14.
 *  Copyright 2014 Catropico. All rights reserved.
 *
 */
#ifndef _NEW_BASE_CAT_H_
#define _NEW_BASE_CAT_H_

#include "cocos2d.h"
#include "Cats/CatStates/CatState.h"
#include "Cats/BaseCat.h"

#include "Supporting/Enums/EnumCatState.h"
#include "Supporting/Enums/EnumCatType.h"
#include "Supporting/Enums/EnumCatInjury.h"

using namespace cocos2d;

class GameMap;
class Character;


class BaseCat: public CCSprite
{
protected:
	//============= TOUCH variables ==============
	bool 			_isSwiped;

	//============= CAT STATE variables =============
	CatState** 		_myCatStates;
	EnumCatState 	_currentCatState,
					_futureCatState,
					_previousCatState;

	//============= ANIMATION variables =============
	float 			RECT_BUFFER_RADIUS; // radius pixels
	bool			_isFlipped;

	//============= SKILL STATUS variables =============
	float			_slowEffectTimer,
					_slowMultiplier;
	bool			_isSlowed;

	//============= SKILL variables =============
	int 			BASE_SKILL_COOLDOWN; // in seconds
	bool 			SKILL_AVAILABLE,
					_skillReady;
	float 			_skillCoolDown,
					_skillCoolDownTimer;
	CCSprite*		_pStatusEffectsLayer;
	CCSprite*		_pImmunityEffectLayer;

	//============= SKILL IMMUNITY variables ============
	int				_numOfImmunities;
	EnumCatInjury*	_immunityList;
	float			_immunityTimer;

	//============= INJURY variables =============
	EnumCatInjury	_injuryType; //used for animation
	float 			BASE_INVUL_DURATION;
	int				_healthReduction;

	//============= MOVEMENT variables =============
	int				VARYING_SPEED, 	// x and y speed
					BASE_SPEED;		//x and y speed
	float 			BASE_SPEED_MULTIPLIER,
					_speedX,
					_speedY,
					_speedMultiplier,
					_directorSpeedMultiplier;

	//============= JUMP variables =============
	int 			BASE_JUMP_HEIGHT,
					BASE_JUMP_SPEED;

	//============= OBSTACLE variables =============
	float 			SLOW_SPEED_MULTIPLIER; // divide the speed multiplier by this
	int				SLOW_DURATION, 		   // in seconds
					BASE_OBSTACLE_HIT_CHANCE,	// %
					_obstacleHitChance;

	//============= ATTACK variables =============
	int 			BASE_ATTACK_RANGE_GRID, 		//attack range in grids
					BASE_ATTACK_DAMAGE,
					BASE_ATK_SPEED,			//atk speed is the pouncing speed
					_attackRange;
	float			_attackSpeedX,
					_attackSpeedY;

	//============= HEALTH variables =============
	int 			BASE_HEALTH,
					_health;

	//============= OTHER variables =============
	EnumCatType 	CAT_TYPE;

	virtual void 	reduceCoolDown(float timeDiff);
	virtual void 	reduceSlowTimer(float timeDiff);
	virtual	void	reduceImmuneTimer(float timeDiff);
	virtual void	initCat();
	virtual void 	initStates();
	virtual void	changeState();
	virtual void 	setImmunity(EnumCatInjury immunity1 = INJURY_NORMAL, EnumCatInjury immunity2 = INJURY_NORMAL, EnumCatInjury immunity3 = INJURY_NORMAL);
	virtual bool	checkImmunity(EnumCatInjury incomingInjury);

public:
	//===== CONSTRUCTOR =====
	BaseCat();

	//===== DESTRUCTOR =====
	~BaseCat();

	//===== STATIC FUNCTIONS =====
	static BaseCat* createCat();

	//===== FUNCTIONS =====
	virtual void 	update(float timeDiff);
	virtual void 	reduceHealth(int healthReduction, EnumCatInjury injuryType = INJURY_NORMAL);
	virtual void	addSlowEffect(float slowDuration, float slowMultiplier);
	virtual float 	move(float timeDiff);
	virtual void	flipCatSprite();

	virtual void	startCoolDownTimer();
	void			stopStatusEffectsLayer();
	void			stopImmuneEffectLayer();


	//===== GETTERS =====
	CCRect 			getRect();
	EnumCatType 	getCatType();
	EnumCatState 	getCurrentCatState();
	EnumCatState	getPreviousCatState();
	bool			isDead();
	bool			isInjured();
	bool			isSwiped();
	bool			isFlipped();
	bool			isSlowed();
	int 			getHealth();
	int				getHealthReduction();
	EnumCatInjury 	getInjuryType();
	int 			getObstacleHitChance();
	int 			getSlowDuration();
	bool 			isSkillReady();
	bool 			isSkillAvailable();
	int 			getAttackRange();
	float 			getSpeedMultiplier();
	float			getDirectorSpeedMultiplier();
	float 			getSpeedX();
	float 			getSpeedY();
	float			getAttackSpeedX();
	float			getAttackSpeedY();
	CCSprite* 		getStatusEffectsLayer();
	CCSprite*		getImmuneEffectLayer();

	int 			getBaseAtkSpeed();
	int 			getBaseAttackDamage();
	int 			getBaseAttackRangeGrid();
	int 			getBaseHealth();
	int 			getBaseJumpHeight();
	int 			getBaseJumpSpeed();
	int 			getBaseObstacleHitChance();
	int 			getBaseSkillCooldown();
	int 			getBaseSpeed();
	float 			getBaseSpeedMultiplier();
	float 			getSlowSpeedMultiplier();
	int 			getVaryingSpeed();
	float			getBaseInvulDuration();

	//===== SETTERS =====
	void 			setNextCatState(EnumCatState currentCatState);
	void			setPreviousCatState(EnumCatState previousCatState);
	void 			setAttackRange(int	attackRange);
	void 			setInjuryType(EnumCatInjury injuryType);
	void 			setObstacleHitChance(int obstacleHitChance);
	void 			setSkillReady(bool skillReady);
	void			setSpeedMultiplier(float speedMultiplier);
	void			setDirectorSpeedMultiplier(float speedMultiplier);
	void 			setSpeedX(float speedX);
	void 			setSpeedY(float speedY);
	void 			setSkillAvailable(bool skillAvailable);
	void			setIsSwiped(bool isSwiped);

};


#endif
